/**
 * Copyright 2018 orivil.com. All rights reserved.
 * Use of this source code is governed by a MIT-style
 * license that can be found at https://mit-license.org.
 */

package mux

import (
	"gitee.com/tugoer/orivil/param"
	"gitee.com/tugoer/orivil/swagger"
)

const (
	Query = param.Query
	Form = param.Form
	Path = param.Path
	Header = param.Header
	Cookie = param.Cookie
)

type Responses map[string]*Response

type Response struct {
	// Required. A short description of the response. GFM syntax can be used
	// for rich text representation.
	Description string

	// A free-form property to include an example of an instance.
	Example interface{}

	// A list of headers that are sent with the response.
	Headers swagger.Headers
}

func (rs Responses) Transform() swagger.Responses {
	sres := make(swagger.Responses, len(rs))
	for code, res := range rs {
		sre := &swagger.Response {
			Description: res.Description,
			Headers:     res.Headers,
		}
		if res.Example != nil {
			sre.Schema = &swagger.Schema{Example: res.Example}
		}
		sres[code] = sre
	}
	return sres
}